
from invoice.models import Invoice
from common.db_util import MySqlDb
"""
    测试保存发票信息
"""
class SaveInvoiceViewTest():
    def save_invoice(self):
        # 构建请求参数
        data = {
            'invoice_type': '普通发票',
            'invoice_code': '20230001',
            'issue_date': '2023-01-01',
            'buyer_name': '张三',
            'buyer_tax_id': '123456789012345678',
            'buyer_address_phone': '13800000000',
            'buyer_bank_account': '6217000000000000000',
            'seller_name': '李四',
            'seller_tax_id': '123456789012345678',
            'seller_address_phone': '13900000000',
            'seller_bank_account': '6217000000000000000',
            'check_code': '123456789012345678',
            'machine_code': '123456789012345678',
            'total_amount': '1000.00',
            'total_tax': '100.00',
            'total_price_tax': '1100.00',
        }
        #连接数据库
        session = MySqlDb.get_mysql_session()
        # 构建模型实例
        invoice = Invoice(**data)
        # 保存模型实例
        session.add(invoice)
        session.commit()
        print("===========执行完毕 =============")



if __name__ == '__main__':
    SaveInvoiceViewTest().save_invoice()
